#include "FlatpakCommand.h"

#include <QProcess>
#include <QTextStream>

QString FlatpakCommand::RunCommand(const QStringList &params) {
    QProcess process;
    process.start(QString("flatpak"), params, QProcess::ReadOnly);
    process.waitForFinished();

    QByteArray stdo = process.readAllStandardOutput();
    QTextStream out(stdout);
    // out << stdo.toStdString().data() <<  "\n";
    QString result = QString::fromLocal8Bit(stdo).trimmed();
    return result;
}

QString FlatpakCommand::RunCommand(const QString childCommand,
                                   const QStringList &params) {
    QStringList arguments;
    arguments << childCommand;
    arguments << params;
    return FlatpakCommand::RunCommand(arguments);
}
